import request from '@/utils/request'

const api = "/api/system/sysUser"

export function login(data) {
  return request({
    url: '/api/system/admin/login',
    method: 'post',
    data
  })
}

export function getInfo(token) {
  return request({
    url: '/api/system/admin/info',
    method: 'get',
    params: { token }
  })
}

export function logout() {
  return request({
    url: '/api/system/admin/logout',
    method: 'post'
  })
}

export function getList(){
  return request({
    url: `${api}/list`,
    method: 'get'
  })
}

export function getPageList(pageNo, pageSize, keyword){
  return request({
    url: `${api}/page/${pageNo}/${pageSize}`,
    method: 'get',
    params: keyword
  })
}

export function saveUser(sysUser){
  return request({
    url: `${api}/save`,
    method:'post',
    data:sysUser
  })
}

export function removeByID(id){
  return request({
    url:`${api}/remove/${id}`,
    method:'delete'
  })
}

export function updateUser(sysUser){
  return request({
    url: `${api}/update`,
    method:'put',
    data:sysUser
  })
}

export function deleteBatch(ids){
  return request({
    url:`${api}/batchRemove`,
    method:'delete',
    data:ids
  })
}

export function toAssign(id){
  return request({
    url:`${api}/toAssign/${id}`,
    method:'get',
  })
}

export function doAssign(id,roleIDs){
  return request({
    url:`${api}/doAssign/${id}`,
    method:'post',
    data:roleIDs
  })
}

// export function uploadAvatar(file){
//   return request({
//     url:'/api/fileUpload',
//     method:'post',
//     params:file
//   })
// }
